package com.yanqu.road.server.manager.union.activitygroup;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.logic.helper.UnionActivityGroupHelper;
import com.yanqu.road.server.CrossBattleServer;
import com.yanqu.road.server.manager.activity.ActivityInfoMgr;
import com.yanqu.road.server.manger.union.BaseUnionActivityGroupMgr;
import com.yanqu.road.utils.ServerType;

public class Cross2UnionActivityGroupMgr extends BaseUnionActivityGroupMgr {

    public static int getGroupId(int activityId, String unionUid) {
        ActivityInfo activityInfo = ActivityInfoMgr.getActivityInfo(activityId);
        if (activityInfo != null) {
            return getGroupId(activityInfo, unionUid);
        }
        return UnionActivityGroupHelper.NO_GROUP_ID;
    }

    public static int getGroupId(int activityId, long userId) {
        ActivityInfo activityInfo = ActivityInfoMgr.getActivityInfo(activityId);
        if (activityInfo != null) {
            return getGroupId(activityInfo, userId);
        }
        return UnionActivityGroupHelper.NO_GROUP_ID;
    }

    public static int getViewDataGroupId(int activityId, long userId){
        int groupId = getGroupId(activityId, userId);
        if(groupId != UnionActivityGroupHelper.NO_GROUP_ID ){
            return groupId;
        }
        ActivityInfo activityInfo = ActivityInfoMgr.getActivityInfo(activityId);
        if(activityInfo != null){
            if(UnionActivityGroupHelper.needGroup(activityInfo)) {
                groupId = UnionActivityGroupHelper.NEED_GROUP_FIRST_ID;
            }else {
                groupId = UnionActivityGroupHelper.NO_NEED_GROUP_ID;
            }
        }
        return groupId;
    }


    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        loadDbData(ServerType.SERVER_CROSS_2, CrossBattleServer.getInstance().getServerId());
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    @Override
    public boolean save() {
        return true;
    }
}
